from typing import TYPE_CHECKING

from sqlalchemy import Boolean, Column, Integer, String, text, TIMESTAMP, BigInteger, Numeric, DateTime, FetchedValue

from app.db.base_class import Base


class Picker(Base):
    __tablename__ = 'tb_picker'

    id = Column(BigInteger, primary_key=True)
    userId = Column('user_id', Integer, nullable=False, info='用户id')
    exchangeId = Column('exchange_id', Integer, nullable=False, info='交易所id')
    marketType = Column('market_type', String(2), nullable=False, info='市场')
    frequency = Column(String(16), info='频率')
    startDate = Column('start_date', DateTime, info='起始时间')
    endDate = Column('end_date', DateTime, info='结束时间')
    pickCount = Column('pick_count', Integer, nullable=False, server_default=FetchedValue(), info='选中数')
    filterCount = Column('filter_count', Integer, nullable=False, server_default=FetchedValue(), info='已筛选数')
    total = Column(Integer, nullable=False, server_default=FetchedValue(), info='总数量')
    publicConditions = Column('public_conditions', String(512), nullable=False)
    strategyConditions = Column('strategy_conditions', String(512), nullable=False)
    createdDate = Column('created_date', TIMESTAMP, server_default=text('CURRENT_TIMESTAMP'))
    updatedDate = Column('updated_date', TIMESTAMP,
                         server_default=text('CURRENT_TIMESTAMP ON UPDATE CURRENT_TIMESTAMP'))

